/*
 * Copyright (c)	2010	Bo Zhou<Bo.Schwarzstein@gmail.com>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 
		http://www.apache.org/licenses/LICENSE-2.0 
 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#pragma once

#include <cassert>
#include <iostream>
#include <set>
#include <valarray>

#include <maya/MColor.h>
#include <maya/MFnMesh.h>
#include <maya/MIntArray.h>
#include <maya/MMatrix.h>
#include <maya/MPointArray.h>
#include <maya/MString.h>

/** \brief Base class for the all XXXMeshSmoothing classes.
 * 
 * MeshSmoothing implements the Average operation as Maya's, but faster than the second one.
 */
class MeshSmoothing
{
public:
	MeshSmoothing(const MObject& MeshObject);
	virtual ~MeshSmoothing();

	void UsePaintedVertices(const bool Use=true);
	bool IsUsingPaintedVertices() const;

	void SetPaintedColor(const MColor& PaintedColor);
	const MColor& GetPaintedColor() const;

	virtual bool Prepare();

	virtual bool Smooth();
protected:
	MFnMesh mMesh;

	//! Painted vertices ids.
	std::valarray<int> mPaintedVertices;
	//! Maximal length of a vertex-polygons.
	int mMaxVertexSharedTime;
	//! Vertices-polygon ids.
	std::valarray<int> mVertexSharedPolygons;
private:
	MColor mPaintedColor;
	bool mUsePaintedVertices;
};
